import 'package:my_flutter_core/my_flutter_core.dart';

/// The service communicates with backend for [Role] usage.
class RoleService {
  final String _url = '/role';
  final HttpRequestService _httpRequestService = HttpRequestService();

  /// Retrieves non system level roles from backend service.
  Future<List<Role>> queryNonSystemLevelRoles() async {
    // Gets the response of the http get request.
    final response =
        await _httpRequestService.get('$_url/query-non-system-level-roles');

    // Parses the data from [Map<String, dynamic>] to [Role].
    return (response.payload as List<dynamic>)
        .map((p) => Role.fromJson(p))
        .toList();
  }
}
